package com.study.designPattern.create.singleton;

/**
 * @author ysy
 * @version 1.0
 * @Title: LazySingleton
 * @Note <b>ProjectName:</b> Pre-research
 * <br><b>PackageName:</b> com.study.designPattern.create.singleton
 * <br><b>ClassName:</b>
 * <br><b>Date:</b>

 */
public class LazySingleton {

    // 定义一个static的本对象
    private static LazySingleton instance;

    private LazySingleton() {
    }

    public static LazySingleton getInstance(){
        if(instance == null){
            instance = new LazySingleton();
        }
        return instance;
    }

    private String name;
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public void whoAreU(String name, Integer age){
        System.out.println("my name is" + name + ", i am " + age + "years old!!");
    }
}
